package com.shenyun.mapper;

import com.shenyun.pojo.Member;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MemberMapper {

    /***
     * 根据学生学号查询成绩记录
     * @param number
     * @return
     */
    @Select("SELECT * FROM student WHERE number = #{number}")
    @Results(id = "studentMap", value = {
            @Result(id = true, property = "number", column = "number"),
            @Result(property = "name", column = "name"),
            @Result(property = "grade", column = "grade"),
            @Result(property = "clbum", column = "clbum"),
            @Result(property = "gender", column = "gender"),
            @Result(property = "age", column = "age"),
            @Result(property = "scores", column = "number", one = @One(
                    select = "com.huyang.mapper.ScoresMapper.queryStudentNumber"))
    })
    Member queryMemberStudent(Integer number);

    /***
     * 根据年级班级查询全部成绩记录
     * @param
     * @return
     */
    @Select("SELECT s.* FROM student s WHERE s.clbum = #{clbum} AND s.grade = #{grade}")
    @Results({
            @Result(id = true, property = "number", column = "number"),
            @Result(property = "name", column = "name"),
            @Result(property = "grade", column = "grade"),
            @Result(property = "clbum", column = "clbum"),
            @Result(property = "gender", column = "gender"),
            @Result(property = "age", column = "age"),
            @Result(column = "number", property = "scores", many = @Many(
                    select = "com.huyang.mapper.ScoresMapper.queryStudentNumber"))
    })
    List<Member> queryMembersStudent(@Param("clbum") String clbum, @Param("grade") String grade);
}
